/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package AdminManagerment.chart;

import java.awt.Dimension;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.RectangleInsets;

/**
 *
 * @author Tngoc
 */
public class TotalInterviewBarChart {
    private ChartFrame frame;
    private JFrame root;
    private DefaultCategoryDataset data;

    public TotalInterviewBarChart(JFrame root, DefaultCategoryDataset data) {
        this.data = data;
        this.root = root;
    }
    
    public void showBarStatistic(int month,int year) {
        // create a chart...
        JFreeChart chart = ChartFactory.createBarChart(
                "Interview Statistic " + month + "/" + year,"Interview status", "count",
                data,PlotOrientation.VERTICAL, true, true, false);
        chart.setPadding(new RectangleInsets(10, 100, 10, 100));
        // create and display a frame...
        frame = new ChartFrame("Statistic", chart);
        frame.pack();
        root.setEnabled(false);
        frame.addWindowListener(new WindowListener() {

            @Override
            public void windowOpened(WindowEvent e) {
            }

            @Override
            public void windowClosing(WindowEvent e) {
                root.setEnabled(true);
            }

            @Override
            public void windowClosed(WindowEvent e) {
            }

            @Override
            public void windowIconified(WindowEvent e) {
            }

            @Override
            public void windowDeiconified(WindowEvent e) {
            }

            @Override
            public void windowActivated(WindowEvent e) {
            }

            @Override
            public void windowDeactivated(WindowEvent e) {
            }
        });
        frame.setVisible(true);
    }
    
    public void showCompanyStatistic(){
        JFreeChart chart = ChartFactory.createBarChart(
                "company Statistic ","Month", "Interview",
                data,PlotOrientation.VERTICAL, true, true, false);
        // create and display a frame...
        frame = new ChartFrame("Statistic", chart);
        frame.pack();
        root.setEnabled(false);
        frame.addWindowListener(new WindowListener() {

            @Override
            public void windowOpened(WindowEvent e) {
            }

            @Override
            public void windowClosing(WindowEvent e) {
                root.setEnabled(true);
            }

            @Override
            public void windowClosed(WindowEvent e) {
            }

            @Override
            public void windowIconified(WindowEvent e) {
            }

            @Override
            public void windowDeiconified(WindowEvent e) {
            }

            @Override
            public void windowActivated(WindowEvent e) {
            }

            @Override
            public void windowDeactivated(WindowEvent e) {
            }
        });
        frame.setVisible(true);
    }
        
}
